/* -------------------------------- Arctic Core ------------------------------
 * Arctic Core - the open source AUTOSAR platform http://arccore.com
 *
 * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
 *
 * This source code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by the
 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * -------------------------------- Arctic Core ------------------------------*/


#ifndef SCHM_CFG_H_
#define SCHM_CFG_H_

#include "Os.h"

#define ECUM_USER_User_1    0

#define SCHM_MAIN_FUNCTION_PERIOD 10

#define SCHM_MAIN_ALARM_CYCLE MS2TICKS(SCHM_MAIN_FUNCTION_PERIOD)

#define SCHM_MF_MEM_PERIOD 		SCHM_MAIN_FUNCTION_PERIOD

/*
 * Scheduling BSW Unit in Ticks(10ms) of SchM_BswService
 */
#define SCHM_CYCLE_MAIN				(1)

#define SCHM_MAINFUNCTION_CYCLE_ADC     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CAN_WRITE     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CAN_READ     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CAN_BUSOFF     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CAN_WAKEUP     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CAN_ERROR     SCHM_CYCLE_MAIN

#define SCHM_MAINFUNCTION_CYCLE_LINSM   SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_LINIF   SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_LINSTP  SCHM_CYCLE_MAIN

#define SCHM_MAINFUNCTION_CYCLE_CANNM   SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CANSM   SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CANTP   SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_CANTRCV SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_COMRX     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_COMTX     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_COMM    SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_DCM     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_XCP     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_DEM     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_ECUM    SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_EA      SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_EEP     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_FEE     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_FLS     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_IOHWAB  SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_NM      SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_OSEKNM  SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_NVM     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_PDUR    SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_SPI     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_WDGM    SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_WDGM_TRIGGER     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_WDGM_ALIVESUPERVISION     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_SOAD     5
#define SCHM_MAINFUNCTION_CYCLE_SD        SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_J1939TP   SCHM_CYCLE_MAIN
/*
 * Schedule BSW memory
 */

#define SCHM_MAINFUNCTION_CYCLE_NVM     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_FEE     SCHM_CYCLE_MAIN
#define SCHM_MAINFUNCTION_CYCLE_FLS     SCHM_CYCLE_MAIN


#define MIAN_FUNCTION_MS2TICKS(name,ms) ((ms + SCHM_MAINFUNCTION_CYCLE_##name*SCHM_MAIN_FUNCTION_PERIOD-1)/(SCHM_MAINFUNCTION_CYCLE_##name*SCHM_MAIN_FUNCTION_PERIOD))

#define MAIN_FUNCTION_PERIOD(name) (SCHM_MAINFUNCTION_CYCLE_##name*SCHM_MAIN_FUNCTION_PERIOD)

#endif /*SCHM_CFG_H_*/
